﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EF6Demo.Model;

namespace EF6Demo
{
    class Program
    {
        static void Main(string[] args)
        {

            using (var db = new BlogContext())
            {
                var b = db.Blogs.Add(new Model.Blog
                {
                    Title = "new Oracle",
                    Author = "Admin",
                    BlogDetail = new Model.BlogDetails
                    {
                        DateCreated = DateTime.Now,
                        Description = "Desc",
                        TimeStamp = Encoding.GetEncoding("gbk").GetBytes("Desc")
                    },
                    Category = BlogCategory.Orace,
                    Content = "Content"
                });
                db.SaveChanges();


                var blogs = db.Blogs.ToList();
                foreach (var blog in blogs)
                {
                    Console.WriteLine(string.Format("ID:{0} \t Blog:{1} \t Category:{2}", blog.BlogId,
                        blog.ListDisplayName, blog.Category));
                }

                Console.ReadKey();
            }
        }
    }
}
